import processing.core.*; 
import processing.xml.*; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class imaginaryBackground extends PApplet {

public void setup() {
  size(800,600);
  background(0);
}



public void draw() {
}

class force {

  particle[] particles;

  force(particle[] particles) {
    this.particles =particles;
  }
}

class particle {

  float x_loc; 
  float y_loc;

  float radius;

  float rotation;
  float velocity;

  float max_velocity;

  particle() {
    radius = random(1,4);
  }

  public void math() {
    clamp_to_stage();
    clamp_velocity();
    clamp_rotation();
    
    set_x();
    set_y();  
  }

  public void clamp_to_stage() {

    if(x_loc <0) {
      x_loc = 1;
      velocity = velocity *-1;
    }

    if(x_loc >width) {
      x_loc = width-1;
      velocity = velocity *-1;
    }

    if(y_loc <0) {
      y_loc = 1;
      velocity = velocity *-1;
    }

    if(y_loc >height) {
      y_loc = height-1;
      velocity = velocity *-1;
    }
  }

  public void clamp_velocity() {
    if(abs(velocity) > max_velocity) {
      if(velocity >0) {
        velocity = max_velocity;
      }
      else
      {
        velocity = max_velocity*-1;
      }
    }
  }

  public void clamp_rotation() {
    if(rotation > 360) {
      rotation = rotation - 360;
    } 
    if(rotation < 0) {
      rotation = rotation + 360;
    }
  }

  public void change_rotation(float rotation) {
    this.rotation = this.rotation+ rotation;
  }

  public void change_velocity(float velocity) {
    this.velocity = this.velocity + velocity;
  }

  public void set_x() {
    x_loc = cos(radians(rotation))*velocity ;
  }

  public void set_y() {
    y_loc = sin(radians(rotation))*velocity ;
  }

  public void render() {
    rect(x_loc,y_loc,radius,radius);
  }
}

class particle_group {

  int number_of_particles; 
  particle[] particles;

  force force;

  public void particle_group(int number_of_particles) {
    particles  = new particle[number_of_particles];

    for(x=0;x<number_of_particles;x++) {
      particles[x] = new particle();
    }

    force = new force(particles);
  }
}

  static public void main(String args[]) {
    PApplet.main(new String[] { "--bgcolor=#DFDFDF", "imaginaryBackground" });
  }
}
